/**
 * @Date 2025-09-26 20:13:15
 * @AIDE AIDE+
 */
package com.goldsprite.gameframeworks.shaders;

import com.badlogic.gdx.math.Vector2;

public class VegetationShader extends BaseShader {
	private final Vector2 wind = new Vector2(0.5f, 0.1f);
	private float swingFrequency = 2.0f;

	// Uniform位置
	private int uTimeLocation;
	private int uWindLocation;
	private int uSwingFrequencyLocation;

	private int uEnableWaveLocation;
	public int uPlantHeightLocation;
	private int uPlantBottomYLocation;

	public int uX0Location;
	public int u_texCoordBottomY;
	public int u_uvSize;
	public int u_uvV2;
	public int u_base_height;
	public int u_swingIntensity;

	public VegetationShader() {
		super("shaders/vegetation.vert", "shaders/vegetation.frag");
	}

	@Override
    protected void initUniforms() {
		uTimeLocation = shaderProgram.getUniformLocation("u_time");
		uPlantBottomYLocation = shaderProgram.getUniformLocation("u_plantBottomY");
		uPlantHeightLocation = shaderProgram.getUniformLocation("u_plantHeight");
		uX0Location = shaderProgram.getUniformLocation("u_x0");
		u_texCoordBottomY = shaderProgram.getUniformLocation("u_texCoordBottomY");
		u_uvSize = shaderProgram.getUniformLocation("u_uvSize");
		u_uvV2 = shaderProgram.getUniformLocation("u_uvV2");
		u_base_height = shaderProgram.getUniformLocation("u_base_height");
		u_swingIntensity = shaderProgram.getUniformLocation("u_swingIntensity");
    }

    @Override
    public void setUniforms() {
        setUniformf(uTimeLocation, getUTime());
        setUniformf(uWindLocation, wind.x, wind.y);
        setUniformf(uSwingFrequencyLocation, swingFrequency);
    }

	public void setWind(float strength, float verticalInfluence) {
		wind.set(strength, verticalInfluence);
	}
	public void setSwingFrequency(float frequency) {
		this.swingFrequency = frequency;
	}

	public void setCurPlantData(float plantBottomY, float  plantHeight) {
		shaderProgram.setUniformf(uPlantBottomYLocation, plantBottomY);
		shaderProgram.setUniformf(uPlantHeightLocation, plantHeight);
	}

	public void setFloatData(float[] fData) {
		shaderProgram.setUniform1fv(uX0Location, fData, 0, fData.length);
	}
}
